package cn.agiledata.bank.transaction.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import cn.agiledata.bank.common.util.Constant;
import cn.agiledata.bank.common.util.ForeDict;
import cn.agiledata.bank.hibernateBean.Bank;
import cn.agiledata.bank.linkbank.service.BankTelPayService;
import cn.agiledata.bank.transaction.form.TelBankInpourForm;
import com.vnv.infrastructure.logic.IPBAppFactory;

/**
 * 电话银行充值
 * 
 * @author maxianbo
 * 
 */
public class TelBankInpourAction extends OnlineInpourAction {

    protected String getActionTypeCode(HttpServletRequest request) {
        return Constant.ACTION_TYPE_B2C_TEL_INPOUR; // 交易类型：B2C电话银行充值
    }

    protected Bank[] getBankList() {
        return getWebPayService().getSupportedTelBanks();
    }

    private BankTelPayService getBankTelPayService() {
        return (BankTelPayService) IPBAppFactory
                .getObj(ForeDict.SERVICE_BANK_TEL_PAY);
    }

    public ActionForward inpour(ActionMapping mapping, ActionForm actionForm,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        TelBankInpourForm form = (TelBankInpourForm) actionForm;
        getBankTelPayService().validateOrderTelephone(form.getOrderTelephone());
        return super.inpour(mapping, actionForm, request, response);
    }

}
